import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';


export const columns: BasicColumn[] = [
  {
    title: '用户名',
    dataIndex: 'userName',
    width: 120,
  },
  {
    title: '昵称',
    dataIndex: 'name',
    width: 120,
  },
  {
    title: '邮箱',
    dataIndex: 'email',
    width: 120,
  },
  {
    title: '创建时间',
    dataIndex: 'creationTime',
    width: 180,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'userName',
    label: '用户名',
    component: 'Input',
    colProps: { span: 8 },
  },
];
export const accountFormSchema: FormSchema[] = [
  {
    field: 'userName',
    label: '用户名',
    component: 'Input',
    helpMessage: ['不能输入带有admin的用户名'],
    rules: [
      {
        required: false,
        message: '请输入用户名',
      },
      // {
      //   validator(_, value) {
      //     return new Promise((resolve, reject) => {
      //       isAccountExist(value)
      //         .then(() => resolve())
      //         .catch((err) => {
      //           reject(err.message || '验证失败');
      //         });
      //     });
      //   },
      // },
    ],
  },
  {
    field: 'password',
    label: '密码',
    component: 'InputPassword',
    ifShow: true,
    //rules: [{ required: true }],
    helpMessage: '密码长度大于6,必须包含一个大写字母和[0-9],[a-Z]以及特殊符号组成',
  },

  {
    field: 'name',
    label: '昵称',
    component: 'Input',
    required: true,
  },

  {
    label: '邮箱',
    field: 'email',
    component: 'Input',
    required: true,
  },
  {
    label: '电话',
    field: 'phoneNumber',
    component: 'Input',
    required: true,
  },
  // {
  //   field: 'selectA',
  //   component: 'Select',
  //   label: '互斥SelectA',
  //   slot: 'selectA',
  //   defaultValue: [],
  //   colProps: {
  //     span: 16,
  //   },
  // },
  {
    label: '角色',
    field: 'roleNames',
    component: 'Select',
    slot: 'selectRoleNames',
    required: true,
  },
  {
    field: 'deptId',
    label: '所属部门',
    component: 'TreeSelect',
    componentProps: {
      replaceFields: {
        title: 'displayName',
        key: 'id',
        value: 'id',
      },
      getPopupContainer: () => document.body,
    },
    required: true,
  },
  {
    label: '状态',
    field: 'isActive',
    component: 'Switch',
    defaultValue: true,
  },
  {
    label: '启用登录错误锁定',
    field: 'lockoutEnabled',
    component: 'Switch',
    defaultValue: false,
  },
];
